{template "header.html"}

{template "api_list_date_search.html"}
<script type="text/javascript">
    function dr_module_delete() {
        var url = '{dr_url(APP_DIR.'/home/del')}&is_iframe=1';
        if (is_mobile_cms == 1) {
            width = height = '90%';
        }
        var data = $("#myform").serialize();
        layer.open({
            type: 2,
            title: '{dr_lang('删除确认')}',
            shadeClose: true,
            shade: 0,
            area: [{php echo \Phpcmf\Service::IS_PC_USER() ? '\'50%\', \'60%\'' : '"95%", "90%"'}],
        btn: [lang['ok']],
            yes: function(index, layero){
            var body = layer.getChildFrame('body', index);
            $(body).find('.form-group').removeClass('has-error');
            // 延迟加载
            var loading = layer.load(2, {
                shade: [0.3,'#fff'], //0.1透明度的白色背景
                time: 5000
            });
            $.ajax({type: "POST",dataType:"json", url: url, data: $(body).find('#myform').serialize(),
                success: function(json) {
                    layer.close(loading);
                    if (json.code == 1) {
                        layer.close(index);
                        $('#mytable').bootstrapTable('refresh');
                    } else {
                        $(body).find('#dr_row_'+json.data.field).addClass('has-error');
                    }
                    dr_tips(json.code, json.msg);
                    return false;
                },
                error: function(HttpRequest, ajaxOptions, thrownError) {
                    dr_ajax_alert_error(HttpRequest, this, thrownError);;
                }
            });
            return false;
        },
        success: function(layero, index){
            // 主要用于后台权限验证
            var body = layer.getChildFrame('body', index);
            var json = $(body).html();
            if (json.indexOf('"code":0') > 0 && json.length < 500){
                var obj = JSON.parse(json);
                layer.close(index);
                dr_cmf_tips(0, obj.msg);
            }
        },
        content: url+'&'+data
    });
    }
    function dr_scjt() {
        $.ajax({
            type: "POST",
            dataType: "json",
            url: "{dr_url($uriprefix.'/scjt_edit')}",
            data: $("#myform").serialize(),
            success: function(json) {
                if (json.code == 1) {
                    dr_bfb('{dr_lang('生成内容')}', '', json.msg);
                } else {
                    dr_cmf_tips(json.code, json.msg);
                }

            },
            error: function(HttpRequest, ajaxOptions, thrownError) {
                dr_ajax_alert_error(HttpRequest, this, thrownError);
            }
        });
    }

    function dr_module_tuigao() {
        var width = '50%';
        var height = '60%';
        if (is_mobile_cms == 1) {
            width = height = '90%';
        }
        var url = '{dr_url(APP_DIR."/home/tui_edit")}&page=6&'+$("#myform").serialize();
        layer.open({
            type: 2,
            title: '{dr_lang("批量退稿确认")}',
            shadeClose: true,
            shade: 0,
            area: [width, height],
            btn: [lang['ok']],
            yes: function(index, layero){
                var body = layer.getChildFrame('body', index);
                $(body).find('.form-group').removeClass('has-error');
                // 延迟加载
                var loading = layer.load(2, {
                    shade: [0.3,'#fff'], //0.1透明度的白色背景
                    time: 5000
                });
                $.ajax({type: "POST",dataType:"json", url: url, data: $(body).find('#myform').serialize(),
                    success: function(json) {
                        if (json.code == 1) {
                            layer.close(index);
                        } else {
                            layer.close(loading);
                            dr_tips(json.code, json.msg);
                            return;
                        }
                        var url2 = json.msg;
                        layer.open({
                            type: 2,
                            title: "{dr_lang('批量退稿进度')}",
                            shadeClose: true,
                            shade: 0,
                            area: [{php echo \Phpcmf\Service::IS_PC_USER() ? '\'50%\', \'60%\'' : '"95%", "90%"'}],
                            btn: [lang['ok'], lang['esc']],
                                yes: function(index, layero){
                                layer.close(loading);
                                var body = layer.getChildFrame('body', index);
                                $(body).find('.form-group').removeClass('has-error');
                                // 延迟加载
                                layer.close(index);
                                setTimeout("window.location.reload(true)", 2000)
                                return false;
                            },
                            success: function(layero, index){
                                // 主要用于后台权限验证
                                layer.close(loading);
                                var body = layer.getChildFrame('body', index);
                                var json = $(body).html();
                                if (json.indexOf('"code":0') > 0 && json.length < 150){
                                    var obj = JSON.parse(json);
                                    layer.close(index);
                                    dr_tips(0, obj.msg);
                                }
                                if (json.indexOf('"code":1') > 0 && json.length < 150){
                                    var obj = JSON.parse(json);
                                    layer.close(index);
                                    dr_tips(1, obj.msg);
                                }
                            },
                            content: url2+'&is_ajax=1'
                        });
                    },
                    error: function(HttpRequest, ajaxOptions, thrownError) {
                        dr_ajax_alert_error(HttpRequest, ajaxOptions, thrownError, this);
                    }
                });
                return false;
            },
            success: function(layero, index){
                // 主要用于后台权限验证
                var body = layer.getChildFrame('body', index);
                var json = $(body).html();
                if (json.indexOf('"code":0') > 0 && json.length < 150){
                    var obj = JSON.parse(json);
                    layer.close(index);
                    dr_tips(0, obj.msg);
                }
                if (json.indexOf('"code":1') > 0 && json.length < 150){
                    var obj = JSON.parse(json);
                    layer.close(index);
                    dr_tips(1, obj.msg);
                }
            },
            content: url+'&is_iframe=1'
        });
    }
</script>

<div class="right-card-box">
    <div id="toolbar" class="toolbar">
    <div class="row table-search-tool">
        <form action="{SELF}" method="get">
            {dr_form_search_hidden($p)}
            {if $is_category_show}
            <div class="col-md-12 col-sm-12">
                <label>
                    {$category_select}
                </label>
            </div>
            {/if}
            <div class="col-md-12 col-sm-12">
                <label>
                    <select name="field" class="form-control">
                        <option value="id"> Id </option>
                        {loop $field $t}
                        {if dr_is_admin_search_field($t)}
                        <option value="{$t.fieldname}" {if $param.field==$t.fieldname}selected{/if}>{dr_lang($t.name)}</option>
                        {/if}
                        {/loop}
                    </select>
                </label>
                <label><i class="fa fa-caret-right"></i></label>
                <label><input type="text" class="form-control" placeholder="" value="{$param['keyword']}" name="keyword" /></label>
            </div>

            <div class="col-md-12 col-sm-12">
                <label>
                    <div class="input-group input-medium date-picker input-daterange" data-date="" data-date-format="yyyy-mm-dd">
                        <input type="text" class="form-control" value="{$param.date_form}" name="date_form">
                        <span class="input-group-addon"> {dr_lang('到')} </span>
                        <input type="text" class="form-control" value="{$param.date_to}" name="date_to">
                    </div>
                </label>
            </div>
            <div class="col-md-12 col-sm-12">
                <label><button type="submit" class="btn blue btn-sm onloading" name="submit" > <i class="fa fa-search"></i> {dr_lang('搜索')}</button></label>
            </div>
        </form>
    </div>
    </div>
    {template "mytable.html"}
</div>

{template "footer.html"}